package org.casper.web;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;

/**
 * Servlet implementation class ValidateEmailIsExistsServlet
 */
public class ValidateEmailIsExistsServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	
	
	@Override
	protected void service(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setCharacterEncoding("utf-8");
		PrintWriter out = response.getWriter();
		String email = request.getParameter("email");
		System.out.println(email);
		
		/**
		 * 拼接的json字符串
		 */
		String json = "{\"email\":\""+email+"\"}";
		
		ArrayList<User> allUsers = new ArrayList<User>();
		allUsers.add(new User(1,"casper","5146"));
		allUsers.add(new User(2,"cherry","605143"));
		String allUserJson = JSON.toJSONString(allUsers);
		
		//out.write(json);
		out.write(allUserJson);
	}
       
   

}
